# -*- coding: utf-8 -*-

import unittest
import os.path

from kivy.lang import Builder

from model.gamestate import GameState, Phase, Players
from presenter_mock import PresenterMock
from start_game import StartGame


class StartGameTest(unittest.TestCase):
    def setUp(self):
        players = Players([])
        self.game_state = GameState(players, None, None, 0, [], None, "")
        Builder.load_file(os.path.join(os.path.dirname(__file__),
                                       'startgame.kv'))

    def test_add_player_button(self):
        self.presenter = PresenterMock(Phase.ADD_PLAYER)
        widget = StartGame(self.game_state, self.presenter)
        widget.add_player()
        self.assertEquals(self.presenter.is_phase_changed, True)

    def test_start_game_button(self):
        self.presenter = PresenterMock(Phase.PLAYERS_ORDER)
        widget = StartGame(self.game_state, self.presenter)
        widget.start_game()
        self.assertEquals(self.presenter.is_phase_changed, True)


if __name__ == '__main__':
    unittest.main()
